/* 
 * File:   main.cpp
 * Author: georgy
 *
 * Created on February, 2012
 */

#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <exception>

#include "Particle.h"
#include "InitParams.h"
#include "MDAlgorithms.h"



int main(int argc, char** argv)
{
    // Initialize random seed.
    srand(time(NULL));
    
    try {
        InitParams                params("input.txt");
        int                       N = params.getNParticles();
        float                     T = params.getTemperature();
        float                     L = params.getLinearSize();
        float                     cutOff = params.getcutOff();
        float                     dt = params.getDeltaT();
        float                     dT = params.getdT();
        std::vector<fltParticle>  particles(N);

        initialize_conditions(particles, L, T);

        do {
            simulation_step(particles, dt, cutOff, L);
            T = calc_temperature(particles);
        } while (T >= dT);

    } catch(const std::exception &ex) {
        std::cout << "The program finished abnormally: "
                  << ex.what() << std::endl;

        return EXIT_FAILURE;
    } catch(const char *ex) {
        std::cout << "The program finished abnormally: "
                  << ex << std::endl;

        return EXIT_FAILURE;
    } catch(...) {
        std::cout << "The program finished abnormally due to unknown error."
                  << std::endl;

        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

